From e4bc73337ab23045f60190e577eb34dcd5f4e7e3 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Tue, 1 Dec 2009 13:34:38 +0000 Subject: [PATCH] libxenlight: fix segfault when reading blktap2 devs This patch fixes a possible segfault when reading from /sys/class/blktap2/devices, if the line read is empty. Signed-off-by: Stefano Stabellini --- tools/libxl/libxl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index abab837952..eaa22253e6 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -937,6 +937,8 @@ static char *get_blktap2_device(struct libxl_ctx *ctx, char *name, char *type) while (!feof(f)) { fscanf(f, "%d %s", &devnum, buf); p = strchr(buf, ':'); + if (p == NULL) + continue; p++; if (!strcmp(p, name) && !strncmp(buf, type, 3)) { fclose(f); -- 2.30.2